<?php session_start(); //START SESSION
include 'countPages.php';
?> 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>PAGE2</title>
    </head>
    <body>

        <?php
              if (!isset($_SESSION['index'])) {   //if values not set set views to 0
            $_SESSION[session_id()];        //get current session id
            $_SESSION['index'] = 0;         //set pageviews to 0
            $_SESSION['page1'] = 0;
            $_SESSION['page2'] = 0;
            $_SESSION['page3'] = 0;

            echo "<p>Your session id is: " . session_id() . "</p>";
            echo "<a href=\"page1.php\" target=\"mainFrame\">go to page 1</a>";
            echo "<a href=\"page2.php\" target=\"mainFrame\">go to page 2</a>";
            echo "<a href=\"page3.php\" target=\"mainFrame\">go to page 3</a>";

            echo "Pageviews = " . $_SESSION['index']; //retrieve data
        }
        else if(isset($_SESSION['index'])){
            $_SESSION['index']+1;
        }
         else if(isset($_SESSION['page1'])){
            $_SESSION['page1']+1;
        }
         else if(isset($_SESSION['page2'])){
            $_SESSION['page2']+1;
        }
         else if(isset($_SESSION['page3'])){
            $_SESSION['page3']+1;
        }
        ?>
    </body>
</html>